package com.common.mq;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {
    // 队列名称
    public static final String QUEUE = "queue";

    /*
    在springboot启动的时候创建一个队列
     */
    @Bean
    public Queue queue() {
        return new Queue(QUEUE, true);
    }

    /*
    消息转换器：将消息转换为JSON格式
     */
    @Bean
    public MessageConverter getMessageConverter() {
        return new Jackson2JsonMessageConverter();
    }

}
